Allow widgets up in the hierarchy to run their DnD handlers if the target
authorCarlos Garnacho <carlos@imendio.com>
Fri, 18 May 2007 11:07:04 +0000 (11:07 +0000)
committerCarlos Garnacho <carlosg@src.gnome.org>
Fri, 18 May 2007 11:07:04 +0000 (11:07 +0000)
2007-05-18  Carlos Garnacho  <carlos@imendio.com>

        * gtk/gtknotebook.c (gtk_notebook_init) (gtk_notebook_drag_motion)
        (gtk_notebook_drag_drop): Allow widgets up in the hierarchy to run
        their DnD handlers if the target doesn't match with anything the
        notebook manages. (#350665, Joakim Lundborg).

svn path=/trunk/; revision=17860

ChangeLog
gtk/gtknotebook.c

index 94bace5f82a4874eba4bb430399fa1a0488ae9ce..46ae683af033f0fea03e1d32f1c53e335c03f6bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-05-18  Carlos Garnacho  <carlos@imendio.com>
+
+       * gtk/gtknotebook.c (gtk_notebook_init) (gtk_notebook_drag_motion)
+       (gtk_notebook_drag_drop): Allow widgets up in the hierarchy to run
+       their DnD handlers if the target doesn't match with anything the
+       notebook manages. (#350665, Joakim Lundborg).
+
 2007-05-18  Carlos Garnacho  <carlos@imendio.com>
 
        Refactor GtkFileChooserDialog sizing.
index 9790d1218e12da2e75a84ed32bff413bd89b42bf..1f63bff41d75b765126da7abfdbd66e4fc43f462 100644 (file)
@@ -1011,8 +1011,7 @@ gtk_notebook_init (GtkNotebook *notebook)
   priv->during_detach = FALSE;
   priv->has_scrolled = FALSE;
 
-  gtk_drag_dest_set (GTK_WIDGET (notebook),
-                    GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+  gtk_drag_dest_set (GTK_WIDGET (notebook), 0,
                     notebook_targets, G_N_ELEMENTS (notebook_targets),
                      GDK_ACTION_MOVE);
 
@@ -3236,19 +3235,18 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
          gdk_drag_status (context, GDK_ACTION_MOVE, time);
          return TRUE;
        }
+      else
+       {
+         /* it's a tab, but doesn't share
+          * ID with this notebook */
+         gdk_drag_status (context, 0, time);
+       }
     }
 
   priv = GTK_NOTEBOOK_GET_PRIVATE (widget);
   x += widget->allocation.x;
   y += widget->allocation.y;
 
-  if (target == tab_target)
-    {
-      /* it's a tab, but doesn't share
-       * ID with this notebook */
-      gdk_drag_status (context, 0, time);
-    }
-
   if (gtk_notebook_get_event_window_position (notebook, &position) &&
       x >= position.x && x <= position.x + position.width &&
       y >= position.y && y <= position.y + position.height)
@@ -3275,7 +3273,7 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
        }
     }
 
-  return TRUE;
+  return (target == tab_target) ? TRUE : FALSE;
 }
 
 static void
@@ -3303,14 +3301,18 @@ gtk_notebook_drag_drop (GtkWidget        *widget,
                        gint              y,
                        guint             time)
 {
-  GdkAtom target;
+  GdkAtom target, tab_target;
 
   target = gtk_drag_dest_find_target (widget, context, NULL);
+  tab_target = gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB");
 
-  if (target == GDK_NONE)
-    gtk_drag_finish (context, FALSE, FALSE, time);
+  if (target == tab_target)
+    {
+      gtk_drag_get_data (widget, context, target, time);
+      return TRUE;
+    }
 
-  return TRUE;
+  return FALSE;
 }
 
 static void